package dao.hibernateImpl;

import java.util.List;

import model.basic.TARGETINTERFACE;

import dao.index.IndexDAO;

public class IndexHibernateImpl extends BaseHibernateImpl  implements IndexDAO{

	private String sql="";
	
	
	public String getSql() {
		return sql;
	}
	public void setSql(String sql) {
		this.sql = sql;
	}

	public List findList(int offset, int length) {
		return this.execSqlQuery(sql,offset,length);
	}
	public StringBuffer buildRalationSql(TARGETINTERFACE ti,String bmID,String ralationtb,String selftb,String targettb,String selfid,String refID){
		StringBuffer sb=new StringBuffer();
		if(ralationtb!=""){
		sb.append(this._leftjoin);
		sb.append(ralationtb);
		sb.append(this._on);
		sb.append(selftb);
		sb.append(this._point);
		sb.append(bmID);
		sb.append(this._eq);
		sb.append(ralationtb);
		sb.append(this._point);
		sb.append(selfid);
		
		sb.append(this._leftjoin);
		sb.append(targettb);
		sb.append(this._on);
		sb.append(ralationtb);
		
		sb.append(this._point);
		sb.append(ti.getTARGETSTR());
		sb.append(this._eq);
		sb.append(targettb);
		sb.append(this._point);
		sb.append(bmID);
		}
		else{
			sb.append(this._leftjoin);
			sb.append(targettb);
			sb.append(this._on);
			sb.append(selftb);
			sb.append(this._point);
			if(refID!=""){
			sb.append(refID);
			}
			sb.append(this._eq);
			sb.append(targettb);
			sb.append(this._point);
			sb.append(bmID);

			
		}
		return sb;
	}
	public StringBuffer buildBasicSql(String column,String table,String where,String orderby){
		
	StringBuffer sb=new StringBuffer();
	sb.append(this.select);
	sb.append(this._space);
	sb.append(column);
	sb.append(this._space);
	sb.append(this.from);
	sb.append(this._space);
	sb.append(table);
	sb.append(this._space);
	sb.append(where);
	sb.append(this._space);
	sb.append(orderby);
	return sb;
	}
}
